<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%@ include file="/resource/include/link_css.jsp"%>

<%@ include file="/resource/include/hander.jsp"%>
<%@ include file="/resource/include/sidebar.jsp"%>

<div class="content-inner">
    <!-- Page Header-->
    <header class="page-header">
        <div class="container-fluid">
            <h2 class="no-margin-bottom">创建调查问卷</h2>
        </div>
    </header>
    <!-- Forms Section-->
    <section class="forms">
        <div class="container-fluid">
            <div class="row">
                <!-- Form Elements -->
                <div class="col-lg-12">
                    <div class="card">
                        <c:if test="${questioncode <= questionnaire.score}">
                        <div class="card-header d-flex align-items-center">
                            <h3 class="h4">第${questioncode}题</h3>
                        </div>
                        <div class="card-body">

                            <form id="question" class="form-horizontal" action="found_question.do" method="post">
                                <input type="hidden" name="ownerquestionnaireid" value="${questionnaire.nid}">
                                <input type="hidden" name="questioncode" value="${questioncode}">
                                    <div class="form-group row">
                                    <label class="col-sm-2 form-control-label"></label>
                                    <label class="col-sm-2 form-control-label">问题类型</label>
                                    <div class="col-sm-5">
                                        <select  name="questiontype" id="type" class="form-control">
                                            <option value="wenda">问答题</option>
                                            <option value="danxuan">单选题</option>
                                            <option value="duoxuan">多选题</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-2 form-control-label"></label>
                                    <label class="col-sm-2 form-control-label">问题名称</label>
                                    <div class="col-sm-5">
                                        <input name="questionheading" type="text" class="form-control">
                                    </div>
                                </div>
                                <div id="checkboxes"   >
                                    <div class="form-group row">
                                        <label class="col-sm-2 form-control-label"></label>
                                        <label class="col-sm-2 form-control-label">选项A</label>
                                        <div class="col-sm-5">
                                            <input name="optiona" type="text"  class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-2 form-control-label"></label>
                                        <label class="col-sm-2 form-control-label">选项B</label>
                                        <div class="col-sm-5">
                                            <input name="optionb" type="text"  class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-2 form-control-label"></label>
                                        <label class="col-sm-2 form-control-label">选项C</label>
                                        <div class="col-sm-5">
                                            <input name="optionc" type="text"  class="form-control">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label class="col-sm-2 form-control-label"></label>
                                        <label class="col-sm-2 form-control-label">选项D</label>
                                        <div class="col-sm-5">
                                            <input name="optiond" type="text"  class="form-control">
                                        </div>
                                    </div>
                                </div>



                                    <button style="margin-left: 40%"  class="btn btn-primary">提交</button>

                            </form>

                        </div>
                        </c:if>

                        <c:if test="${questioncode > questionnaire.score}">

                            <button onclick="yulan(${questionnaire.nid})"
                                    style="margin-left: 40% ;width: 60px"  class="btn btn-primary">预览</button>
                        </c:if>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- Page Footer-->

</div>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script type="text/javascript" >
    $(function() {
        //隐藏div
        $("#checkboxes").hide();
        //给div添加change事件
        $("#type").change(function() {
            if($(this).val() == 'wenda' ) {
                $("#checkboxes").hide();

            } else if($(this).val() == 'danxuan' ) {
                $("#checkboxes").show();

            }
            else if($(this).val() == 'duoxuan' ) {
                $("#checkboxes").show();
            }
        })
    })
    function yulan(id){
       $("#question").submit()
        var x = window.screen.height;
        var y = window.screen.width;
        var h = 600;
        var w = 700;
        var model = "title=word,resizable=yes,scrollbars=yes," +
            "height=" + h + ",width=" + w + ",status=no,toolbar=no" +
            ",menubar=no,location=no,top=" + (x-h)/4 + ",left=" + (y-w)/2;

        var url = "naire_show.do/"+id;//弹出窗口的页面内容
        var oOpen = window.open(url,"adviceDetail",model);
        oOpen.focus();
    }
</script>

<%@ include file="/resource/include/link_js.jsp"%>